package com.game.spacetrader.TradeGoods;

import com.game.spacetrader.R;
import com.game.spacetrader.map.MapView;

import android.app.TabActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.Window;
import android.widget.TabHost;

/**
 * Contains tabs for Market and Hull
 */
@SuppressWarnings("deprecation")
public class TradeGoodsView extends TabActivity {
	@Override
	public void onCreate(Bundle savedInstanceState){
		super.onCreate(savedInstanceState);
		requestWindowFeature(Window.FEATURE_NO_TITLE);
		setContentView(R.layout.tradegoods);
		
		TabHost tabHost = (TabHost)findViewById(android.R.id.tabhost);
		
		tabHost.addTab(tabHost.newTabSpec("tab1")
		        .setIndicator("Hull")
		        .setContent(new Intent(this, TradeGoodsHull.class).addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)));
		 tabHost.addTab(tabHost.newTabSpec("tab2")
		        .setIndicator("Market")
		        .setContent(new Intent(this, TradeGoodsMarket.class).addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)));
	}
	
	/**
	 * Creates option menu
	 */
	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		getMenuInflater().inflate(R.menu.activity_space_trader, menu);
	    return true;
	}
	
	/**
     * Listener for the options menu
     * @param item the item in the Menu that is clicked
     */
    @Override
	public boolean onOptionsItemSelected(MenuItem item) {
	    switch (item.getItemId()) {
	        case R.id.travel:
	        	Intent i = new Intent(this, MapView.class);
	        	startActivity(i);
	            return true;
	        case R.id.market:
	        	Intent i2 = new Intent(this, TradeGoodsView.class); startActivity(i2);
	        	return true;
	        default:
	            return super.onOptionsItemSelected(item);
	    }
	}
}
